package com.dhwl.hsh.driver.ui.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;


import com.dhwl.hsh.lib.view.viewpagerindicator.IconPagerAdapter;
import com.dhwl.hsh.driver.R;

import java.util.List;
/**
 * banner适配器
 * @author Derek.Kidd
 * @time 2016/4/20 18:33
 */
public class BannerViewPagerAdapter extends FragmentPagerAdapter implements IconPagerAdapter
{
    private List<Fragment> fragmentsList;
    
    private int[] icons;
    
    public BannerViewPagerAdapter(FragmentManager  fm)
    {
        super(fm);
    }
    
    public BannerViewPagerAdapter(FragmentManager  fm, List<Fragment> fragments)
    {
        super(fm);
        this.fragmentsList = fragments;
        icons = new int[fragments.size()];
        for (int i = 0; i < fragments.size(); i++)
        {
            icons[i] = R.drawable.selector_index_icon;
        }
    }
    
    @Override
    public Fragment getItem(int arg0)
    {
        return fragmentsList.get(arg0);
    }
    
    @Override
    public int getCount()
    {
        return fragmentsList.size();
    }
    
    @Override
    public int getItemPosition(Object object)
    {
        return super.getItemPosition(object);
    }
    
    @Override
    public int getIconResId(int index)
    {
        return icons[index % icons.length];
    }
    
}
